home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Tool Chest / Developer Utilities / Installer 4.0.3 SDK / Script Examples / File Compression Example / fileCompress.r < prev    next >
Encoding:
Text File  |  1994-11-15  |  15.8 KB  |  455 lines  |  [TEXT/MPS ]

  1. //
  2. //    fileCompress.r    - an example of how to use InstaCompOne compression
  3. //
  4. //
  5. //    How To Build the Script:
  6. //    
  7. //        To build Installer script access "Build…" item within "Build" menu
  8. //        and enter the scriptName "fileCompress". To build the Installer
  9. //        debugger version of the Installer script enter the scriptname
  10. //        with the addition ".debug" ( "fileCompress.debug" ).
  11. //
  12. //        There must be a copy of the file "InstaCompOneSCExt.rsrc"
  13. //        that has been renamed to "fileCompress.scx" included in this
  14. //        folder as well. This file will automatically be copied and
  15. //        renamed ( from the InstaCompOne folder in the SDK ) when the
  16. //        makefile for this example is run.
  17. //
  18. //    What this example does :
  19. //
  20. //        This Installer script source demonstrates use of InstaCompOne 
  21. //        archives, split files, the InstaCompOneTool compression utility, 
  22. //        and the FileAndRsrcSplitterTool for use in installing files.
  23. //
  24. //        All target files from example installations are placed in a folder 
  25. //        called ":InstaComp Testing:" on the root folder of the target volume 
  26. //        of installation. Performing a "GetInfo" on the resulting file(s) will 
  27. //        display information identifying from which method the file was installed.
  28. //        The three methods are: file compression, file splitting, file compression
  29. //        and splitting.
  30. //
  31. //    IMPORTANT: You must use the flag "rsrcForkInDataFork" in file atoms when using
  32. //    InstaCompOne to compress files. This enables the Installer to find the compressed
  33. //    resource fork in the data fork of the archive file.
  34. //
  35. //    NOTE: InstaCompOne can be used to split and compress resources and fonts 
  36. //    in addition to files, but this example deals only with splitting and 
  37. //    compressing files. The major difference between working with files and 
  38. //    working with resources ( and fonts ) is that compressed items will usually 
  39. //    be stored in the data fork of an archive when working with files and will 
  40. //    be stored in the resource fork of an archive when working with resources 
  41. //    and fonts.
  42. //
  43. //
  44. //    The following MPW commands for compression and splitting are already
  45. //    contained in the makefile for this example.  They have been included 
  46. //    here for your convenience.  Running the makefile will demonstrate all
  47. //    the commands listed below.
  48. //
  49. //  • simple file compression example ( no splitting )
  50. //
  51. //    - To compress "TeachText • 1" into an archive called "Tome" within "Disk 1:"
  52. //    InstaCompOneTool "TeachText • 1" -o ":Disk 1:Tome"
  53. //
  54. //
  55. //    • split and compressed file example
  56. //
  57. //    - To split a file into two resource forks :
  58. //    FileAndRsrcSplitterTool "TeachText • 2" -s 20000 -o "splitCompTeachText"
  59. //    - this will result in two files within the current folder
  60. //    - named "splitCompTeachText.rsrc1" and "splitCompTeachText.rsrc2"
  61. //
  62. //    - To compress the first split piece into an archive in ":Disk 1:"
  63. //    InstaCompOneTool "splitCompTeachText.rsrc1" -o ":Disk 1:splitCompTome1" -f "TeachText • 2" -e
  64. //
  65. //    - To compress the second split piece into an archive in ":Disk 2:"
  66. //    InstaCompOneTool "splitCompTeachText.rsrc2" -o ":Disk 2:splitCompTome2" -f "TeachText • 2" -e
  67. //
  68. //    • simple split file example ( no compression )
  69. //
  70. //    - To split a file into two resource forks :
  71. //    FileAndRsrcSplitterTool "TeachText • 3" -s 20000 -o "splitTeachText"
  72. //    - this will result in two files within the current folder
  73. //    - named "splitTeachText.rsrc1" and "splitTeachText.rsrc2"
  74. //
  75. //    - To place both these pieces in the installation disk folders :
  76. //    Duplicate "splitTeachText.rsrc1" -y ":Disk 1:splitTome1"
  77. //    Duplicate "splitTeachText.rsrc2" -y ":Disk 2:splitTome2"
  78. //
  79. //
  80. //
  81. //
  82. //    NOTE: Always use the target filename ( contained in the target file 
  83. //    spec 'intf' ) when compressing a file into an archive. This will 
  84. //    ensure that the InstaCompOne decompression utility can successfully 
  85. //    locate and decompress the contents of the archive during installation. 
  86. //    A full target path for the destination file should be entered in the 
  87. //    'intf' resource, but only the actual filename will be used when extracting 
  88. //    compressed file items from within an archive.
  89. //
  90. //     NOTE: When using InstaCompOne compression and splitting, simply enter 241
  91. //     as the value for the atom extender ( 'inex' ) in the next to last field
  92. //     of the atom ( 'infa', 'inff', 'inra' ) for the file/font/rsrc to be
  93. //     decompressed.  There is no need to declare an 'inex' resource within the
  94. //     Installer script source.  An 'inex' resource definition is contained in
  95. //     the InstaCompOne resource file that is included at the top of this file.
  96. //
  97. //
  98. //
  99. //        mark young • 08/17/94
  100. //    
  101. //        Copyright 1993-1994, Apple Computer, Inc., All Rights Reserved
  102. //
  103.  
  104. #include "InstallerTypes.r"
  105.  
  106. // Include the InstaCompOne atom extender stuff
  107. // making sure not to add their version resource
  108. // to our installer script. Also, since this include
  109. // is a resource include instead of a #include, it is
  110. // not actually a pre-processor thing, and won't be effected
  111. // by a -i option within the rez line in the makefile. 
  112. include ":::InstaCompOne 1.0:InstaCompOneAtomExt.rsrc" NOT 'vers';
  113.  
  114.  
  115. // • packages
  116.  
  117. // package that demonstrates simple case of archive, 
  118. //    one file in archive decompressed to target volume
  119. resource 'inpk' (100) {
  120.     format0 {
  121.         showsOnCustom,
  122.         removable,
  123.         dontForceRestart,
  124.         0,
  125.         0,
  126.         "TeachText - using InstaCompOne compression.",
  127.         {    
  128.         'infa', 1000;
  129.         },
  130.     }
  131. };
  132.  
  133. // package that demonstrates decompressing two archives and 
  134. //    joining the results into one target file
  135. resource 'inpk' (200) {
  136.     format0 {
  137.         showsOnCustom,
  138.         removable,
  139.         dontForceRestart,
  140.         0,
  141.         0,
  142.         "TeachText - using file splitting and InstaCompOne compression.",
  143.         {    
  144.         'infa', 2000;
  145.         },
  146.     }
  147. };
  148.  
  149. // package that demonstrates decompressing two archives and 
  150. //    joining the results into one target file
  151. resource 'inpk' (300) {
  152.     format0 {
  153.         showsOnCustom,
  154.         removable,
  155.         dontForceRestart,
  156.         0,
  157.         0,
  158.         "TeachText - using file splitting, but no compression.",
  159.         {    
  160.         'infa', 3000;
  161.         },
  162.     }
  163. };
  164.  
  165.  
  166. // • file atoms
  167.  
  168. // • simple compression example
  169. // single source file => single archive => single target file
  170. resource 'infa' (1000) {
  171.     format1 {
  172.         deleteWhenRemoving,                //  Delete on deinstall
  173.         deleteWhenInstalling,            //  Remove preexisting
  174.         copy,                            //  Copy on Install
  175.         dontIgnoreLockedFile,            //  Respect file locking
  176.         dontSetFileLocked,                //  Leave installed file unlocked
  177.         useSrcCrDateToCompare,            //  Use creation date for compare
  178.         srcNeedNotExist,                //  Create a new file if necessary
  179.         
  180.         // this line must be set to "rsrcForkInDataFork" when working 
  181.         // file items compressed into InstaCompOne archives
  182.         rsrcForkInDataFork,                //  • Resource fork in Data fork
  183.         
  184.         leaveAloneIfNewer,                //  Do not update a newer file
  185.         updateExisting,                    //  Update an existing file
  186.         copyIfNewOrUpdate,                //  Copy whether target exists or not
  187.         rsrcFork,                        //  Copy resource fork
  188.         dataFork,                        //  Copy data fork
  189.         
  190.         0,                    // TARGET - size ( filled in by ScriptCheck )
  191.         0x0,                // finder attribute flags ( filled in by ScriptCheck )
  192.         10000,                // TARGET - file spec ( 'intf' )
  193.         {    
  194.             10001,            // SOURCE - file spec ( 'infs' )
  195.             0,                 // DATA fork - size ( filled in by ScriptCheck )
  196.             0                // RSRC fork - size ( filled in by ScriptCheck )
  197.         },    
  198.         
  199.         0x0,                // SOURCE - version number for comparisons
  200.                             // not used here
  201.                             
  202.         0,                    // 'invc' code resource - version comparison routine 
  203.                             //    ( none used here )
  204.         
  205.         241,                // 'inex' resource definition for atom extender
  206.                             // • #241 is for InstaCompOne extender
  207.                             
  208.         "TeachText • 1"        // file atom description
  209.     }
  210. };
  211.  
  212.  
  213. // • split file compression example
  214. // single source file => split resource fork => 2 archives => single target file
  215. resource 'infa' (2000) {
  216.     format1 {
  217.         deleteWhenRemoving,                //  Delete on deinstall
  218.         deleteWhenInstalling,            //  Remove preexisting
  219.         copy,                            //  Copy on Install
  220.         dontIgnoreLockedFile,            //  Respect file locking
  221.         dontSetFileLocked,                //  Leave installed file unlocked
  222.         useSrcCrDateToCompare,            //  Use creation date for compare
  223.         srcNeedExist,                    //  Require a source file
  224.         
  225.         // this line must be set to "rsrcForkInDataFork" when working 
  226.         // file items compressed into InstaCompOne archives
  227.         rsrcForkInDataFork,                //  • Resource fork in Data fork
  228.         
  229.         leaveAloneIfNewer,                //  Do not update a newer file
  230.         updateExisting,                    //  Update an existing file
  231.         copyIfNewOrUpdate,                //  Copy whether target exists or not
  232.         rsrcFork,                        //  Copy resource fork
  233.         dataFork,                        //  Copy data fork
  234.         
  235.         0,                    // TARGET - size ( filled in by ScriptCheck )
  236.         0x0,                // finder attribute flags ( filled in by ScriptCheck )
  237.         20000,                // TARGET - file spec ( 'intf' )
  238.         {    
  239.             // • IMPORTANT - the split and compressed pieces must be listed
  240.             // • in the same order here as when they were split. In other
  241.             // • words the piece that was split off first ( and was given
  242.             // • the ".rsrc1" ending ) should be listed first in the lines below.
  243.             // • then comes the piece with the ".rsrc2" ending, etc.
  244.             
  245.             20001,            // SOURCE - file spec ( 'infs' )
  246.             0,                 // DATA fork - size ( filled in by ScriptCheck )
  247.             0,                // RSRC fork - size ( filled in by ScriptCheck )
  248.             
  249.             20002,            // SOURCE - file spec ( 'infs' )
  250.             0,                 // DATA fork - size ( filled in by ScriptCheck )
  251.             0                // RSRC fork - size ( filled in by ScriptCheck )
  252.         },    
  253.         
  254.         0x0,                // SOURCE - version number for comparisons,
  255.                             // not used here
  256.                             
  257.         0,                    // 'invc' code resource - version comparison routine 
  258.                             //    ( none used here )
  259.         
  260.         
  261.         241,                // 'inex' resource definition for atom extender
  262.                             // • #241 is for InstaCompOne extender
  263.                             
  264.         "TeachText • 2"        // file atom description
  265.     }
  266. };
  267.  
  268.  
  269.  
  270. // • split file w/o compression example
  271. // single source file => split resource fork => single target file
  272. resource 'infa' (3000) {
  273.     format1 {
  274.         deleteWhenRemoving,                //  Delete on deinstall
  275.         deleteWhenInstalling,            //  Remove preexisting
  276.         copy,                            //  Copy on Install
  277.         dontIgnoreLockedFile,            //  Respect file locking
  278.         dontSetFileLocked,                //  Leave installed file unlocked
  279.         useSrcCrDateToCompare,            //  Use creation date for compare
  280.         srcNeedExist,                    //  Require a source file
  281.         
  282.         // this line must be set to "rsrcForkInDataFork" when working 
  283.         // file items compressed into InstaCompOne archives
  284.         rsrcForkInDataFork,                //  • Resource fork in Data fork
  285.         
  286.         leaveAloneIfNewer,                //  Do not update a newer file
  287.         updateExisting,                    //  Update an existing file
  288.         copyIfNewOrUpdate,                //  Copy whether target exists or not
  289.         rsrcFork,                        //  Copy resource fork
  290.         
  291.         noDataFork,                        //  • Don't Copy data fork
  292.                                         //     'noDataFork' must be set
  293.                                         //     when splitting the resource
  294.                                         //     fork but not compressing the pieces
  295.                                         
  296.         0,                    // TARGET - size ( filled in by ScriptCheck )
  297.         0x0,                // finder attribute flags ( filled in by ScriptCheck )
  298.         30000,                // TARGET - file spec ( 'infs' )
  299.         {    
  300.             // • IMPORTANT - the split pieces must be listed in the
  301.             // • same order here as when they were split. In other
  302.             // • words the piece that was split off first ( and was given
  303.             // • the ".rsrc1" ending ) should be listed first in the lines below.
  304.             // • then comes the piece with the ".rsrc2" ending, etc.
  305.             
  306.             30001,            // SOURCE - file spec ( 'infs' )
  307.             0,                 // DATA fork - size ( filled in by ScriptCheck )
  308.             0,                // RSRC fork - size ( filled in by ScriptCheck )
  309.             
  310.             30002,            // SOURCE - file spec ( 'infs' )
  311.             0,                 // DATA fork - size ( filled in by ScriptCheck )
  312.             0                // RSRC fork - size ( filled in by ScriptCheck )
  313.         },    
  314.         
  315.         0x0,                // SOURCE - version number for comparisons
  316.                             // not used here
  317.                             
  318.         0,                    // 'invc' code resource - version comparison routine 
  319.                             //    ( none used here )
  320.         
  321.         
  322.         0,                    // 'inex' resource definition for atom extender
  323.                             // don't use atom extender for simple split files
  324.                             
  325.         "TeachText • 3"            // file atom description
  326.     }
  327. };
  328.  
  329.  
  330. // • compressed - file specs
  331.  
  332. // • simple compression
  333. // target file spec for decompressed "TeachText" application 
  334. resource 'intf' (10000) {
  335.     format1 {
  336.         noSearchForFile,        // use default search path
  337.         TypeCrNeedNotMatch,        // target type and creator don't have to match
  338.         'APPL',                    // TYPE given to new file
  339.         'ttxt',                    // CREATOR given to new file
  340.         
  341.         0x0,                    // Target - finder flags
  342.                                 //    ( ScriptCheck fills in flags if set to 0 )
  343.         
  344.         0x1,                    // Target - creation date 
  345.         0x1,                    // Target - mod date 
  346.                                 //    ( ScriptCheck fills in dates if set to 1 )
  347.                                 
  348.         0,                        // 'insp' resource ID ( file search proc )
  349.         ":File Compression Example:TeachText • 1"    // path to target file
  350.     }
  351. };
  352.  
  353.  
  354. // • simple compression
  355. // source file spec for compressed "TeachText" application 
  356. resource 'infs' (10001) {
  357.     'idcp',                        // TYPE 
  358.     'kakc',                        // CREATOR 
  359.     0x0,                        // creation DATE for source file
  360.     noSearchForFile,            // IGNORED in Installer 4.0.x
  361.     TypeCrMustMatch,            // TYPE, CREATOR must match file on install disk
  362.     "Disk 1:Tome"                // PATH to source file        
  363. };
  364.  
  365. // • split and compressed - file specs
  366.  
  367. // • split resource fork with compression
  368. // shared target file spec to result from joining split pieces in archives 
  369. resource 'intf' (20000) {
  370.     format1 {
  371.         noSearchForFile,        // use default search path
  372.         TypeCrNeedNotMatch,        // target type and creator don't have to match
  373.         'APPL',                    // TYPE given to new file
  374.         'ttxt',                    // CREATOR given to new file
  375.         
  376.         0x0,                    // Target - finder flags
  377.                                 //    ( ScriptCheck fills in flags if set to 0 )
  378.         
  379.         0x1,                    // Target - creation date 
  380.         0x1,                    // Target - mod date 
  381.                                 //    ( ScriptCheck fills in dates if set to 1 )
  382.                                 
  383.         0,                        // 'insp' resource ID ( file search proc )
  384.         ":File Compression Example:TeachText • 2"    // path to target file
  385.     }
  386. };
  387.  
  388. // • split resource fork with compression
  389. // source file spec for archive containing one piece of split file 
  390. resource 'infs' (20001) {
  391.     'idcp',                        // TYPE 
  392.     'kakc',                        // CREATOR 
  393.     0x0,                        // creation DATE for source file
  394.     noSearchForFile,            // IGNORED in Installer 4.0.x
  395.     TypeCrMustMatch,            // TYPE, CREATOR must match file on install disk
  396.     "Disk 1:splitCompTome1"        // PATH to source file        
  397. };
  398.  
  399. // • split resource fork with compression
  400. // source file spec for archive containing one piece of split file 
  401. resource 'infs' (20002) {
  402.     'idcp',                        // TYPE 
  403.     'kakc',                        // CREATOR 
  404.     0x0,                        // creation DATE for source file
  405.     noSearchForFile,            // IGNORED in Installer 4.0.x
  406.     TypeCrMustMatch,            // TYPE, CREATOR must match file on install disk
  407.     "Disk 2:splitCompTome2"        // PATH to source file        
  408. };
  409.  
  410. // • split - file specs
  411.  
  412. // • split resource fork with compression
  413. // shared target file spec to result from joining split pieces in archives 
  414. resource 'intf' (30000) {
  415.     format1 {
  416.         noSearchForFile,        // use default search path
  417.         TypeCrNeedNotMatch,        // target type and creator don't have to match
  418.         'APPL',                    // TYPE given to new file
  419.         'ttxt',                    // CREATOR given to new file
  420.         
  421.         0x0,                    // Target - finder flags
  422.                                 //    ( ScriptCheck fills in flags if set to 0 )
  423.         
  424.         0x1,                    // Target - creation date 
  425.         0x1,                    // Target - mod date 
  426.                                 //    ( ScriptCheck fills in dates if set to 1 )
  427.                                 
  428.         0,                        // 'insp' resource ID ( file search proc )
  429.         ":File Compression Example:TeachText • 3"    // path to target file
  430.     }
  431. };
  432.  
  433. // • split resource fork with compression
  434. // source file spec for archive containing one piece of split file 
  435. resource 'infs' (30001) {
  436.     'splt',                        // TYPE 
  437.     'heyu',                        // CREATOR 
  438.     0x0,                        // creation DATE for source file
  439.     noSearchForFile,            // IGNORED in Installer 4.0.x
  440.     TypeCrMustMatch,            // TYPE, CREATOR must match file on install disk
  441.     "Disk 1:splitTome1"            // PATH to source file        
  442. };
  443.  
  444. // • split resource fork with compression
  445. // source file spec for archive containing one piece of split file
  446. resource 'infs' (30002) {
  447.     'splt',                        // TYPE 
  448.     'heyu',                        // CREATOR 
  449.     0x0,                        // creation DATE for source file
  450.     noSearchForFile,            // IGNORED in Installer 4.0.x
  451.     TypeCrMustMatch,            // TYPE, CREATOR must match file on install disk
  452.     "Disk 2:splitTome2"            // PATH to source file        
  453. };
  454.  
  455.